package com.hp.ssm.service.impl;

import com.hp.ssm.mapper.UserMapper;
import com.hp.ssm.pojo.User;
import com.hp.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User的业务逻辑实现类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @Transactional(rollbackFor = Exception.class,isolation = Isolation.REPEATABLE_READ)
    @Override
    public void update() throws Exception {
        userMapper.updatePwd("001","999");
        if(2 == 1){
            throw new RuntimeException("test");
        }
        userMapper.updatePwd("002","999");
    }
}
